<?php
/**
 * Created by PhpStorm.
 * User: iceberg
 * Date: 2018-10-02
 * Time: 16:13
 */

namespace app\base\controller;
use app\service\UnitService;
use think\Controller;
use think\facade\Request;


class Unit extends Controller
{
    //单位业务
    private $unitServer;
    //初始化方法
    public function initialize()
    {
        $this->unitServer = new UnitService();
    }

    //显示列表
    public function index()
    {
        $this->assign('list', $this->unitServer->page());
        $this->assign('count', $this->unitServer->count());
        return $this->fetch();
    }

    //显示创建页面
    public function create()
    {
        return $this->fetch();
    }

    //添加单位
    public function save()
    {
        //return json($this->unitServer->save());
        return $this->unitServer->save();
    }

    //显示编辑界面
    public function edit($id)
    {
        $this->assign(['info'  =>  $this->unitServer->edit($id)]);
        return $this->fetch();
    }

    //更新
    public function update()
    {
        return $this->unitServer->update();
    }

    //删除
    public function delete($id)
    {
        return $this->unitServer->delete($id);
    }
}